package com.dawn.module.cms.dal.mysql.banner;

import java.util.*;

import com.dawn.framework.common.pojo.PageResult;
import com.dawn.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dawn.framework.mybatis.core.mapper.BaseMapperX;
import com.dawn.module.cms.dal.dataobject.banner.CmsBannerDO;
import org.apache.ibatis.annotations.Mapper;
import com.dawn.module.cms.controller.admin.banner.vo.*;

/**
 * Banner 广告位 Mapper
 *
 * @author mamba 4 left
 */
@Mapper
public interface CmsBannerMapper extends BaseMapperX<CmsBannerDO> {

    default PageResult<CmsBannerDO> selectPage(CmsBannerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CmsBannerDO>()
                .eqIfPresent(CmsBannerDO::getTitle, reqVO.getTitle())
                .eqIfPresent(CmsBannerDO::getPicUrl, reqVO.getPicUrl())
                .eqIfPresent(CmsBannerDO::getUrl, reqVO.getUrl())
                .eqIfPresent(CmsBannerDO::getStatus, reqVO.getStatus())
                .eqIfPresent(CmsBannerDO::getSort, reqVO.getSort())
                .eqIfPresent(CmsBannerDO::getPosition, reqVO.getPosition())
                .eqIfPresent(CmsBannerDO::getMemo, reqVO.getMemo())
                .eqIfPresent(CmsBannerDO::getBrowseCount, reqVO.getBrowseCount())
                .betweenIfPresent(CmsBannerDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CmsBannerDO::getId));
    }

}